//
//  ViewController.m
//  Objc进阶Demo
//
//  Created by Don't update on 2018/7/14.
//  Copyright © 2018年 Don't update. All rights reserved.
//

#import "ViewController.h"
#import "ListeningModelController.h"
#import "DelegateModelController.h"
#import "ThirdViewController.h"
#import "AnimationListController.h"
#import "GCDTestController.h"
#import "MasonryUseController.h"
#import "OptimumPropertyController.h"
#import "SqliteUseController.h"
#import "MJExtensionVC.h"
#import "QQListController.h"
#import "BinaryTreeController.h"
@interface ViewController ()<UITableViewDataSource,UITableViewDelegate>
@property(nonatomic,strong)UITableView *tableview;
@property(nonatomic,strong)NSArray *list;



@end

@implementation ViewController



-(NSArray *)list{
    if (_list == nil) {
        _list = [[NSArray alloc]initWithObjects:@"代理模式",@"监听模式",@"视图跳转",@"动画",@"GCD",@"Masonry的使用",@"图片圆角性能优化",@"数据库sqlite",@"MJExtension",@"qq列表实现" ,@"二叉树",nil];
    }
    return _list;
}

-(UITableView *)tableview{
    if (_tableview == nil) {
        _tableview = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
        _tableview.delegate = self;
        _tableview.dataSource = self;
        [self.view addSubview:_tableview];
    }
    return _tableview;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self list];
    [self tableview];
    

    
    
}
#pragma marl ---tableview代理
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return _list.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifity = @"cell_id";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifity];
    if (cell == nil) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifity];
    }
    cell.textLabel.text = _list[indexPath.row];
    return  cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    

    NSInteger i = indexPath.row;
    switch (i) {
        case 0:{
            NSLog(@"代理模式");
            DelegateModelController *deVc = [[DelegateModelController alloc]init];
            [self.navigationController pushViewController:deVc animated:YES];}
            break;
        case 1:{
            NSLog(@"监听者模式");
            ListeningModelController *lisVc = [[ListeningModelController alloc]init];
            [self.navigationController pushViewController:lisVc animated:YES];
        }
            break;
        case 2:{
            NSLog(@"视图跳转");
            ThirdViewController *thirVc = [[ThirdViewController alloc]init];
            [self.navigationController pushViewController:thirVc animated:YES]; 
        }
            break;
        case 3:{
            NSLog(@"动画");
            AnimationListController *animVc = [[AnimationListController alloc]init];
            [self.navigationController pushViewController:animVc animated:YES];
        }
            break;
        case 4:{
            NSLog(@"GCD");
            GCDTestController *gcdVC = [[GCDTestController alloc]init];
            [self .navigationController pushViewController:gcdVC animated:YES];
        }
            break;
        case 5:{
            NSLog(@"Masonry的使用");
            MasonryUseController *masVC = [[MasonryUseController alloc]init];
            [self.navigationController pushViewController:masVC animated:YES];
        }
            break;
        case 6:{
            NSLog(@"图片圆角性能优化");
            OptimumPropertyController *opVC = [[OptimumPropertyController alloc]init];
            [self.navigationController pushViewController:opVC animated:YES];
        }
        case 7:{
            NSLog(@"数据库");
            SqliteUseController *sqVC = [[SqliteUseController alloc]init];
            [self.navigationController pushViewController:sqVC animated:YES];
        }
            break;
        case 8:{
            NSLog(@"MJExtension");
            MJExtensionVC *mjVC = [[MJExtensionVC alloc]init];
            [self.navigationController pushViewController:mjVC animated:YES];
        }
        case 9:{
            NSLog(@"qq列表实现");
            QQListController *qqVC = [[QQListController alloc]init];
            [self.navigationController pushViewController:qqVC animated:YES];
        }
            break;
        case 10:{
            NSLog(@"二叉树");
            BinaryTreeController *biTreeVC = [[BinaryTreeController alloc]init];
            [self.navigationController pushViewController:biTreeVC animated:YES];
        }
        default:
            break;
    }
}


@end
